
package ui;

import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.list.ListCellRenderer;
import com.sun.lwuit.plaf.Border;

/**
 *
 * @author Meera
 */
public class IntakeListRenderer extends Container implements ListCellRenderer {

    private Label item = new Label("");
    private Label qty = new Label("");
    //private Label unit = new Label("");
    private Label cals = new Label("");
    private Label unit = new Label("");
    private Label focus = new Label("");

    public IntakeListRenderer() {
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS));
        Container cnt2 = new Container(new BoxLayout(BoxLayout.X_AXIS));

        item.getStyle().setBgTransparency(0);
        item.getStyle().setBorder(Border.createLineBorder(1, 0x000000));
        qty.getStyle().setBgTransparency(0);
        qty.getStyle().setBorder(Border.createLineBorder(1, 0x000000));
        unit.getStyle().setBgTransparency(0);
        unit.getStyle().setBorder(Border.createLineBorder(1, 0x000000));
        cals.getStyle().setBgTransparency(0);
        cals.getStyle().setBorder(Border.createLineBorder(1, 0x000000));

        item.setPreferredW(80);
        qty.setPreferredW(40);
        unit.setPreferredW(40);
        cals.setPreferredW(60);

        item.setPreferredH(25);
        qty.setPreferredH(25);
        unit.setPreferredH(25);
        cals.setPreferredH(25);

        cnt2.addComponent(item);
        cnt2.addComponent(qty);
        cnt2.addComponent(unit);
        cnt2.addComponent(cals);
        cnt.addComponent(cnt2);

        addComponent(cnt);
        focus.setFocus(true);

    }

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {

        IntakeItem obj1 = (IntakeItem) value;

        item.setText(obj1.getItem());
        qty.setText(obj1.getQty());
        unit.setText(obj1.getUnit());
        cals.setText(obj1.getCals());
        return this;
    }

    public Component getListFocusComponent(List list) {
        return focus;
    }
}
